# $Id: PKGBUILD 83235 2013-01-28 14:43:38Z tredaelli $
# Maintainer: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: darkcoder <mario_vazq@hotmail.com>

pkgname=os-prober
pkgver=1.57
pkgrel=3
pkgdesc="Utility to detect other OSes on a set of drives"
url="http://joey.kitenet.net/code/os-prober/"
arch=('i686' 'x86_64')
license=('GPL3')
depends=('sh')
source=(ftp://ftp.debian.org/debian/pool/main/o/${pkgname}/${pkgname}_${pkgver}.tar.gz)
md5sums=('67548b17d55cc32c1168bb5a4061170d')
sha256sums=('d63c6cbb825a7e411aac5e4805edc6db2fbf77a59282b71c10bd29723b8d860c')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  # adjust lib dir to allow detection of 64-bit distros
  sed -i -e "s:/lib/ld\*\.so\*:/lib*/ld*.so*:g" os-probes/mounted/common/90linux-distro

  rm -f Makefile
  make newns
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm755 linux-boot-prober "$pkgdir"/usr/bin/linux-boot-prober
  install -Dm755 os-prober "$pkgdir"/usr/bin/os-prober
  install -Dm755 newns "$pkgdir"/usr/lib/os-prober/newns
  install -Dm755 common.sh $pkgdir/usr/share/os-prober/common.sh  

  for dir in os-probes os-probes/mounted os-probes/init linux-boot-probes linux-boot-probes/mounted; do
    install -dm755 "$pkgdir/usr/lib/$dir"
    install -m755 -t "$pkgdir/usr/lib/$dir" "$dir"/common/*
    [[ -d "$dir"/x86 ]] && install -m755 -t "$pkgdir/usr/lib/$dir" "$dir"/x86/*
  done

  install -Dm755 os-probes/mounted/powerpc/20macosx "$pkgdir"/usr/lib/os-probes/mounted/20macosx

  install -dm755 "$pkgdir"/var/lib/os-prober
}
